/**
 * 
 */
package com.d6game.test;

import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;

/**
 * @author dell
 *
 */
public class CalculateCall implements Callable<Integer> {
	public CountDownLatch startSignal;  
	public CountDownLatch doneSignal;
	public Integer group;
	

	public CalculateCall(CountDownLatch startSignal, CountDownLatch doneSignal, Integer group) {
		this.startSignal = startSignal;
		this.doneSignal = doneSignal;
		this.group = group;
	}
	@Override
	public Integer call() throws Exception {
		startSignal.await();
		int sum = 0;
		int start = (group-1)*10+1;
		int end = group*10;
		System.out.println("开始计算第"+group+"组");
		for(int i = start; i<= end; i++){
			sum += i;
		}
		System.out.println("结束计算第"+group+"组:"+sum);
		doneSignal.countDown();
		return sum;
	}

}
